package com.thymeleaf.study.study_thymeleaf.controller;

import com.thymeleaf.study.study_thymeleaf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Date;

/**
 * Created by fangjicai on 2020/5/14.
 */

@Controller
public class HelloController {
    @GetMapping("/show1")
    public String show1(Model model){
        model.addAttribute("msg","hello thymeleaf !");
        return "hello";
    }

    @GetMapping("show2")
    public String show2(Model model){
        User user = new User();
        user.setAge(21);
        user.setName("Jack Chen");
        user.setId(1);
        user.setSex("女");
        model.addAttribute("user", user);
        return "show2";
    }

    @GetMapping("show3")
    public String show3(Model model){
        model.addAttribute("today", new Date());
        return "show3";
    }
}
